package com.longshen.dubbo.api.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.longshen.dubbo.api.mapper.AdminRoleTradeMapper;
import com.longshen.dubbo.api.model.AdminRoleTrade;
import com.longshen.dubbo.api.sequence.SequenceService;
import com.longshen.dubbo.api.service.AdminRoleTradeService;

@Service
public class AdminRoleTradeServiceImpl implements AdminRoleTradeService {
	
	@Autowired
	private AdminRoleTradeMapper  mapper;
	
	@Autowired
	private SequenceService seq;

	@Override
	public void addTrades(String roleid, List<String> trades) {
		
		if(trades !=null && !trades.isEmpty()) {
			trades.forEach(tradeId->{
				AdminRoleTrade art=new AdminRoleTrade();
				art.setId(seq.getId());
				art.setRoleId(roleid);
				art.setTradeId(tradeId);
				mapper.insert(art);
			});
		}

	}

	@Override
	public void dellRoleTrade(String roleid, String tradeid) {
		AdminRoleTrade art=new AdminRoleTrade();
		art.setRoleId(roleid);
		art.setTradeId(tradeid);
		mapper.delete(art);
	}

	

}
